package com.hualan.sfzy.controller.consult;

import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.model.entity.ConsultEvaluate;
import com.hualan.sfzy.model.vo.ConsultEvaluateVO;
import com.hualan.sfzy.service.impl.consult.ConsultEvaluateServiceImpl;
import com.hualan.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/consultEvaluate")

// 咨询师评价控制类
public class ConsultEvaluateController {
    @Autowired
    private ConsultEvaluateServiceImpl service;

    @PostMapping
    public Result add(@RequestBody ConsultEvaluate entity){
        return service.add(entity)>0?Result.success():Result.error();
    }

    @DeleteMapping("/{id}")
    public Result remove(@PathVariable Integer id){
        return service.remove(id)>0?Result.success():Result.error();
    }
    @DeleteMapping
    public Result removeBatch(Integer[] ids){
        return service.removeBatch(ids)>0?Result.success():Result.error();
    }

    @GetMapping
    public Result find(){
        return Result.success(service.findAll());
    }
    @GetMapping("/page")
    public Result findPage(@RequestParam(value = CommonConstant.PAGE_NUM,required = false,defaultValue = CommonConstant.PAGE_NUM_DEFAULT) Integer pageNum,
                          @RequestParam(value = CommonConstant.PAGE_SIZE,required = false,defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) Integer pageSize,
                          ConsultEvaluateVO entity){
        return Result.success(service.findPagePro(pageNum,pageSize,entity));
    }

    @GetMapping("/userId/{id}")
    public Result findByUserId(@PathVariable Integer id){
        return Result.success(service.findByUserId(id));
    }
    @GetMapping("/consultId/{id}")
    public Result findByConsultId(@PathVariable Integer id){
        return Result.success(service.findByConsultId(id));
    }
}
